home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1994 November / macformat-018.iso / Utility Spectacular / Developer / MPW Extras ƒ / MPW / Scripts / CommentLine next >
Encoding:
Text File  |  1991-07-29  |  1.2 KB  |  50 lines  |  [TEXT/MPS ]

  1. # CommentLine - Comment-out a selection of program lines in the active window
  2.  
  3. Set GoOn 1
  4. If {#} >= 2
  5.     # impose comment type
  6.     If "{2}" == "-a"
  7.         # assembler
  8.         Set ComStr "; "
  9.     Else
  10.         If "{2}" == "-m"
  11.             # MPW script
  12.             Set ComStr "# "
  13.         Else
  14.             If "{2}" == "-c"
  15.                 # C or C++
  16.                 Set ComStr "∂/∂/ "
  17.             Else
  18.                 Alert "{0}:∂nUsage: {0} [-a | -m | -c]"
  19.                 Set GoOn 0
  20.             End  # If "{2}"
  21.         End  # If "{2}"
  22.     End  # If "{2}"
  23. Else
  24.     # infer comment type from file extension
  25.     Set GoOn 1
  26.     Set Extension "`Echo "{Active}" | StreamEdit -d -e '/(.≈)®1/ Print ®1' ≥ Dev:Null`"
  27.     If (({Extension} == ".a") || ({Extension} == ".A") || ({Extension} == ".Asm") || ({Extension} == ".Asm"))
  28.         # assembler
  29.         Set ComStr1 "; "
  30.     Else
  31.         If (({Extension} == ".C") || ({Extension} == ".h") || ({Extension} == ".r") || ({Extension} == ".C") || ({Extension} == ".H") || ({Extension} == ".R"))
  32.             # C, C++, or Rez
  33.             Set ComStr "∂/∂/ "
  34.         Else
  35.             If {Extension} == ""
  36.                 # MPW script
  37.                 Set ComStr "# "
  38.             Else
  39.                 Alert "{0}:∂nCan't determine comment style from file extension"
  40.                 Set GoOn 0
  41.             End  # If {Extension}
  42.         End  # If {Extension}
  43.     End  # If {Extension}
  44. End  # If {#}
  45.  
  46. If ({GoOn} == 1)
  47.     ColumnShiftTool -r "{ComStr}"
  48. End  # If {GoOn}
  49.  
  50. # end of CommentLine